//
//  WBStatusTableViewCell.swift
//  Weibo
//
//  Created by kobe on 2016/12/26.
//  Copyright © 2016年 kobe. All rights reserved.
//

import UIKit

class WBStatusTableViewCell: UITableViewCell {
    
    var viewModel:WBStatusViewModel? {
        didSet {
            statusLabel?.text = viewModel?.status.text

            nameLabel.text = viewModel?.status.user?.screen_name
            
//            timeLabel.text = viewModel?.status.created_at
//            
//            sourceLabel.text = viewModel?.status.source
            
            //设置会员
            memberIconView.image = viewModel?.memberIcon
            
            vipIconView.image = viewModel?.vipIcon
            
            iconView.cz_setImage(urlStr: viewModel?.status.user?.profile_image_url, placeholderImage: UIImage(named: "avatar_default_big"),isAvatar: true)
            
            //底部工具
            toolBar.viewModel = viewModel
            
            //配图视图模型
            pictureView.viewModel = viewModel
            
            //修改配图视图的高度
//            pictureView.heighCons.constant = viewModel?.pictureSize.height ?? 0
            //设置配图视图的数据
//            if (viewModel?.status.pic_urls?.count)! < 4 {
//                var pics = viewModel!.status.pic_urls!
//                pics.removeSubrange((pics.startIndex + 4)..<pics.endIndex)
//                pictureView.urls = pics
//            } else {
//                pictureView.urls = viewModel?.status.pic_urls
//            }
            
            
            /// 设置
            pictureView.urls = viewModel?.picURLs
            retweetedLabel?.text = viewModel?.retweetedText
            
        }
    }
    
    
    @IBOutlet weak var iconView: UIImageView!
    
    @IBOutlet weak var nameLabel: UILabel!
    
    @IBOutlet weak var memberIconView: UIImageView!
    
    @IBOutlet weak var timeLabel: UILabel!
    
    @IBOutlet weak var sourceLabel: UILabel!
    
    @IBOutlet weak var vipIconView: UIImageView!
    
    @IBOutlet weak var statusLabel: UILabel!
    
    
    @IBOutlet weak var toolBar: WBStatusToolbar!
    
    @IBOutlet weak var pictureView: WBStatusPictureView!
    
    //被转发微博内容  原创微博没有子控件 要用 ?
    @IBOutlet weak var retweetedLabel: UILabel?
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
